/*
 * ValueNode.h
 *
 *  Created on: 28 Sep 2011
 *      Author: s0965328
 */

#ifndef VALUENODE_H_
#define VALUENODE_H_

#include "SyntaxNode.h"

#include <sstream>

/** @class ValueNode
 *  Represents a value.
 */
template<class T> class ValueNode : public SyntaxNode
{
  public:
   const T value;

  public:
   ValueNode(const T new_value) :
      SyntaxNode(-99), value(new_value) {}
   double getFloatVal() const { return value; }
   std::string getValue() const;
   void findIDREF(std::list<ModelComp*> &lmc) { return; }
   void findIDREF(std::list<SyntaxNode*> *lnd) { return; }
   // We never search for INT_VAL or FLOAT_VAL:
   void findOpCode(int oc, std::list<SyntaxNode*> *lnd) { return; }
   std::ostream& put(std::ostream&s) const { return s << this->value; }
   SyntaxNode *deep_copy() { return new ValueNode<T>(value); }
   SyntaxNode *clone() { return deep_copy(); }
};

template<class T> std::string ValueNode<T>::getValue() const
{
   std::ostringstream ost;
   ost << value;
   return ost.str();

}



#endif /* VALUENODE_H_ */
